<?php

/**
 * This is the model class for table "linkman".
 *
 * The followings are the available columns in table 'linkman':
 * @property integer $id
 * @property string $no
 * @property integer $cid
 * @property string $name
 * @property string $department
 * @property string $job
 * @property string $role
 * @property string $mobile
 * @property string $landline
 * @property string $fax
 * @property string $email
 * @property string $birthday
 * @property string $remark
 * @property integer $createuser
 * @property string $cusername
 * @property string $createtime
 * @property string $updatetime
 * @property integer $isdel
 */
class Linkman extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'linkman';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('cid, createuser, isdel', 'numerical', 'integerOnly'=>true),
			array('no, job, landline, fax, birthday', 'length', 'max'=>20),
			array('name, department, role, email, cusername', 'length', 'max'=>50),
			array('mobile', 'length', 'max'=>11),
			array('remark, createtime, updatetime', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, no, cid, name, department, job, role, mobile, landline, fax, email, birthday, remark, createuser, cusername, createtime, updatetime, isdel', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'no' => '联系人编号',
			'cid' => '客户id',
			'name' => '联系人姓名',
			'department' => '部门',
			'job' => '职务',
			'role' => '角色',
			'mobile' => '手机',
			'landline' => '座机',
			'fax' => '传真',
			'email' => '邮箱',
			'birthday' => '生日',
			'remark' => '备注',
			'createuser' => '创建人id',
			'cusername' => '创建人账号',
			'createtime' => '创建时间',
			'updatetime' => '修改时间',
			'isdel' => 'Isdel',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('no',$this->no,true);
		$criteria->compare('cid',$this->cid);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('department',$this->department,true);
		$criteria->compare('job',$this->job,true);
		$criteria->compare('role',$this->role,true);
		$criteria->compare('mobile',$this->mobile,true);
		$criteria->compare('landline',$this->landline,true);
		$criteria->compare('fax',$this->fax,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('birthday',$this->birthday,true);
		$criteria->compare('remark',$this->remark,true);
		$criteria->compare('createuser',$this->createuser);
		$criteria->compare('cusername',$this->cusername,true);
		$criteria->compare('createtime',$this->createtime,true);
		$criteria->compare('updatetime',$this->updatetime,true);
		$criteria->compare('isdel',$this->isdel);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Linkman the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
